package com.ruoyi.parkingcar.service.impl;

import com.ruoyi.parkingcar.domain.ParkCar;
import com.ruoyi.parkingcar.mapper.ParkCarMapper;
import com.ruoyi.parkingcar.service.ParkCarService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ParkCarServiceImpl  implements ParkCarService {

    @Autowired
    private ParkCarMapper parkCarMapper;

    @Override
    public int insertParkCar(ParkCar parkCar) {
        parkCar.setCarStatus(0);
        return parkCarMapper.insertParkCar(parkCar);
    }

    @Override
    public ParkCar selectParkCar(String licensePlate) {

        return parkCarMapper.allCar(licensePlate);
    }


    //Vant,前端我的车辆
    @Override
    public int AddLicensePlate(ParkCar parkCar) {
        return parkCarMapper.AddLicensePlate(parkCar);
    }

    @Override
    public List<ParkCar> CarByAcc(ParkCar parkCar) {
        return parkCarMapper.CarByAcc(parkCar);
    }

    @Override
    public int deleteCar(ParkCar parkCar) {
        return parkCarMapper.deleteCar(parkCar);
    }

    @Override
    public int updateCar(ParkCar parkCar) {
        if(parkCarMapper.selectCar(parkCar.getLicensePlate()) == null){
            return parkCarMapper.updateCar(parkCar);
        }else
            return 0;
    }
}
